<!--
 * @Description: 
 * @Author: jun.wu
 * @Date: 2022-12-06 14:45:24
 * @LastEditors: jun.wu
 * @LastEditTime: 2022-12-06 15:03:46
-->
<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <!-- 放一个图标 -->
    <div>
      <svg-icon style="color: #fff; font-size: 20px" icon-class="language" />
    </div>
    <!-- 下拉图标 -->
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="'zh' === $i18n.locale"
        >中文</el-dropdown-item
      >
      <el-dropdown-item command="en" :disabled="'en' === $i18n.locale"
        >en</el-dropdown-item
      >
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from "js-cookie";
export default {
  methods: {
    changeLanguage(type) {
      // 设置类型en
      //   先写入cookie
      Cookie.set("language", type);
      this.$i18n.locale = type;
      this.$message.success("切换语言成功");
    },
  },
};
</script>

<style></style>
